package cargarDatos.convertirArchivos;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
import rutas.GetRoutes;

public class _template {
	static BufferedReader input;
	
	static StringTokenizer _stk;
	static String readln() throws IOException{
		String l=input.readLine();
		if(l!=null) _stk=new StringTokenizer(l,",");
		return l;
	}
	
	static String next(){return _stk.nextToken();}
	static int nextInt(){return Integer.parseInt(next());}
	
	static void dbg(Object...o) {
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) throws IOException {
		
//		PrintWriter output = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		Locale.setDefault(Locale.US);
//		input=new BufferedReader(new InputStreamReader(System.in));
                String archivo=GetRoutes.escogerRutaArchivo();
		input=new BufferedReader(new FileReader(archivo));
                PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(archivo+".out")));
                
                String tabla=JOptionPane.showInputDialog("A que tabla va a guardar los datos?");
                while(readln()!=null){
                    output.printf("INSERT INTO %s VALUES (",tabla);
                    if(_stk.hasMoreTokens()){
                        String dato=next();
                        try {
                            output.print(Integer.parseInt(dato));
                        } catch (Exception e) {
                            if(dato.equals(""))
                                output.print("NULL");
                            else
                                output.printf("\"%s\"",dato);
                        }
                    }
                    while(_stk.hasMoreTokens()){
                        String dato=next();
//                        System.out.println(dato);
                        try {
                            output.print(","+Integer.parseInt(dato));
                        } catch (Exception e) {
                            if(dato.equals(""))
                                output.print(",NULL");
                            else
                                output.printf(",\"%s\"",dato);
                        }
                    }
                    
                    output.println(")");
                }
		output.close();
	}
}
